package edu.webtek.cloudresp;

import org.jdom2.Document;
import org.jdom2.Element;

public class RespLogin  extends RespBase {
	private final int customerID;
	private final String customerName;
	
	public int getCustomerID() {
		return customerID;
	}
	public String getCustomerName() {
		return customerName;
	}

	public RespLogin(Document resp) {
		int customerID = -1;
		String customerName = "NULL";
		if(resp == null){
			this.customerID = customerID;
			this.customerName = customerName;
			flagResponseError();
			return;
		}
		
		for(Element attr : resp.getRootElement().getChildren()){
			String data = attr.getText();
			
			switch(attr.getName()){
			case "customerID":
					customerID = Integer.parseInt(data);
				break;
			case "customerName":
				customerName = data;
				break;
			}
		}
		
		this.customerID = customerID;
		this.customerName = customerName;
	}
	
}
